beginoutdoorscript;

variables;
short choice = 0;
short pc_cycle = 0;

body;

beginstate 0; //INIT_STATE

break;

beginstate 1; //EXIT_STATE

break;

beginstate 2; //START_STATE

break;

beginstate 4; //Guards
	outdoor_enc_result(1);
	if(get_flag(201, 14) != 1) {
		reset_dialog();
		add_dialog_str(0, "Walking by the road, you run into a group of patrolling guards. Once they see that you're not lizards, they approach you." , 0);
		add_dialog_str(1, "_You might want to watch yourselves out here._ a guard tells you. _There are more lizards out here than we've ever seen before, and we can't protect everyone._", 0);
		add_dialog_str(2, "You quietly assure them that you can handle a few lizards, and they depart uneasily. From the look of them, you're not sure that those guards could handle a drake between them. Hopefully, you can help them before things in the valley get really bad.", 0);
		run_dialog(1);
	 	set_flag(201,14,1);
		}
	else {
		print_str("You greet the guards on the road.");
		}
break;

beginstate 5; //Approach Relias
	if(get_flag(200, 2) != 1) {
		reset_dialog();
		message_dialog("You approach the valley's capital city, Relias. From here you can see that it's a somewhat small farming town, and that it looks fairly peaceful.","However, you can see signs of lizard attacks in the surrounding farms, and few farmers are out in the fields. Those who are carry spears and swords, as if expecting an attack any minute.");
		set_flag(200,2,1);
		}
	break;

beginstate 6; //Approach Fort Ouranil
	if (get_flag(200,6) != 1) {
		reset_dialog();
		message_dialog("Traveling north, you see a strange sight at the foot of the cliff which forms the valley's north side. At first, it looks like a regular fort, like any Empire fort. However, it looks like it was built into the rock of the cliff itself!","You're getting very impressed with the druids' work in the valley, as strange as it may be.");
		set_flag(200,6,1);
		}
	break;

beginstate 7; //general farmhouse
	block_entry(1);
	message_dialog("This appears to be a normal farmhouse, with a few livestock wandering about. However, you can tell that the farmers are slightly on edge, particularly given how many are carrying swords.","These people don't look like they want to talk with you... the lizards appear to have put them on edge.");
	break;

beginstate 8; //Approach the Sanctum
	if(get_flag(200,3) != 1) {
		message_dialog("As you walk through the valley, you notice something strange about the hill towering above you. The top of the hill is encircled by a thick grove of trees, with only a small opening on the south side.","Might be something worth checking out.");
		set_flag(200,3,1);
		}
	break;

beginstate 9; //Leave the scenario
	block_entry(1);
	reset_dialog();
	add_dialog_str(0, "Nearing the tunnel which exits the valley, you begin to think of what may lie beyond this narrow valley, just waiting to be killed.",0);
	add_dialog_str(1, "Do you wish to leave the scenario?", 0);
	add_dialog_choice(0, "No. I wish to continue exploring the valley.");
	add_dialog_choice(1, "Yes, I've got better things to do.");
	choice = run_dialog(1);
	if(choice == 2) {
		end_scenario(0); 
		}
break;

//STATES 10-19 Relias mines

beginstate 10; //mine- (lizard encounter)
	block_entry(1);
	if((get_flag(200,0) != 1) && (get_flag(5,5) == 1)) {       //First attempt, and only if you've spoken with Mayor M.
		reset_dialog();
		add_dialog_str(0, "As you approach the mines near Relias, you hear the screams of terrified mine workers. Sensing that you're about to fight something, you wait for someone to tell you what to do.",0);
		add_dialog_str(1, "It isn't long before a partially-singed miner runs up to you, screaming about an infestation of lizards and hydras in the mines.", 0);
		add_dialog_str(2, "It seems an adventurer's work is never done. Time to slash some lizards...", 0);
		add_dialog_choice(0, "Charge!");
		run_dialog(1);
		create_out_spec_enc(0);
		set_flag(200,0,1);
		}
	else {      //After a success, or if haven't spoken to Mayor M.
		reset_dialog();
		add_dialog_str(0, "You visit the mines near Relias, hoping to find something of interest. However, the miners are rather busy, and are working hard on whatever it is that they do.", 0);
		add_dialog_str(1, "Before you can even try to look around, a few miners calmly escort you to the exit.", 0);
		add_dialog_str(2, "_We're sure you understand, but we really can't have random people wandering in and out of the mines... it's just bad policy._ they say apologetically.", 0);
		add_dialog_choice(0, "Okay.");
		run_dialog(1);
		}
break;

beginstate 11; //Start lizard encounter
	set_out_fight_town_loaded(1026);
break;

beginstate 12; //If you fled
	reset_dialog();
	message_dialog("Well, you might've outran the lizards, but it seems that they can run much faster than you.", "");
	create_out_spec_enc(0);

break;

beginstate 13; //Killed the lizards
	reset_dialog();
	add_dialog_str(0, "As you walk away from the pile of dead lizards, a few miners walk up to you cautiously, unsure of your sanity.",0);
	add_dialog_str(1, "Once they're sure that you won't attack them, they thank you profusely. _We owe you one._",0);
	add_dialog_str(2, "_That's the biggest group of lizards that we've ever seen around here. Normally we can take care of them, but that was just too much for us._", 0);
	add_dialog_str(3, "_We can't really offer you much of a material reward, but rest assured that we are forever in your debt._", 0);
	add_dialog_str(4, "_We need to go clear out the dead lizards, but if you talk to the mayor of Relias, he'll probably give you a good reward._", 0);
	add_dialog_str(5, "The miners go back to work, this time shifting dead lizards instead of rocks. You think it's best to leave before they start to smell.", 0);
	run_dialog(1);
	set_flag(200,1,1);
	inc_flag(100,2,1);
break;



//STATES 20-29 - Liam's Trading Post

beginstate 20; //Start enc.
	if(get_flag(200,4) != 1) {
		reset_dialog();
		add_dialog_str(0, "You pass the small hedge surrounding this small house, and immediately sense that something is amiss. While the ruined crops tell you something, it's the incredibly loud hissing sound that grabs your attention.", 0);
		add_dialog_str(1, "Running toward the hissing sound, you see a huge group of lizards standing around a tree. It seems like they're waiting for something. Then a rock falls out of the tree and hits a lizard.",0);
		add_dialog_str(2, "_Take that!_ you hear, and then you see that somebody's in the tree, hiding from the lizards! There's no way to tell how long he's been up there, but you charge in anyway, hoping to save the unfortunate soul.", 0);
		add_dialog_choice(0, "Charge!");
		run_dialog(1);
		set_flag(200,4,1);
		create_out_spec_enc(1);
		}
break;

beginstate 21; //Set custom fight town
	reset_dialog();
	set_out_fight_town_loaded(8);
break;

beginstate 22; //Killed Liam's lizards
	reset_dialog();
	add_dialog_str(0, "Having killed the last of the lizards, the man in the tree leaps out onto the ground. It looks like he's been stuck up there for at least a day.",0);
	add_dialog_str(1, "_Thank you._ the man says. _My name is Liam, and I was attacked in the night. I ran up here before they could kill me. I could only grab a few rocks before getting up there, so there wasn't much I could do._", 0);
	add_dialog_str(2, "_I used to run a full trading post, but the lizards probably destroyed almost all of my stock. I should probably go check on what's left..._ he says, starting to walk over to the roughly clawed house.", 0);
	add_dialog_str(3, "Liam comes back after a few minutes, clutching a sling. _Yep, it's almost completely destroyed. This was all that survived. Go ahead and take it... I really should repay you somehow._", 0);
	add_dialog_str(4, "Handing you the sling, he continues. _Well, all I can say is that I'll have to recommend you to the Order, and that I'm eternally grateful. Anyway, I've got to start cleaning up._", 0);
	add_dialog_str(5, "You leave him to fix his ruined home.", 0);
	run_dialog(1);
	char_give_item(0,315);
	award_party_xp(500,20);
	inc_flag(100,2,1); //Chalk up another quest point for Oakleaf
	break;

beginstate 23; //Liam again
	reset_dialog();
	block_entry(1);
	message_dialog("You return to Liam's trading post, and find him still trying to repair his shop and home. He invites you into what's left of his house for some coffee, and you talk for a while.","He's still unable to reopen his shop, but that doesn't seem to bother him. You leave him to his work.");
break;